package com.drama.outtake.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.drama.outtake.domain.enums.Gender;
import com.drama.outtake.domain.enums.OrderStatus;
import com.drama.outtake.util.CustomGenderDeserializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @Author : 李先均
 * @Date 2022/12/21 10:06
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Builder
@Table(name = "orders") //order是MySQL的关键字，所以需要替换一下
@TableName("orders")
public class Order {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @TableId(type = IdType.AUTO)
    private Long id;
    @Enumerated(EnumType.STRING)
    private OrderStatus status;
    private LocalDateTime createTime;
    private LocalDateTime updateTime;
    private Long shopId;
    private Double packageFees;
    private Double deliveryFees;
    private Double totalCost;
    private String deliverer;//TODO 用作支付方式
    private Long userId;  //下单用户的ID
    private String sn;
    //下面和用户相关的信息只是和订单相关的信息
    private String userName;
    @Enumerated(EnumType.STRING)
    @JsonDeserialize(using = CustomGenderDeserializer.class)
    private Gender userGender;
    private Long userPhone;
    private String userAd;
    private LocalDateTime deliverTime;
    private String remark;
    private Integer cutleryNumber;
    @Transient
    @TableField(exist = false)
    private List<CartItem> items;
}
